<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2017/6/7
 * Time: 下午4:41
 */


//一句话实现定义一个函数并立即调用
call_user_func(function () {
    echo __FUNCTION__ . PHP_EOL;
});

function call()
{
    echo __FUNCTION__ . PHP_EOL;
}

call_user_func('call');


call_user_func_array(function ($a, $b, $c, $d) {
    echo $a, $b, $c, $d;
}, [1, 2, 3, 4]);

var_dump(error_get_last());


//上下文变量

$context = "hello,world";
$context2 = "hello,world";
call_user_func(function () use ($context, $context2) {
    echo $context . ' ' . $context2 . PHP_EOL;
});